package application;

import java.util.ArrayList;

import com.db4o.Db4oEmbedded;
import com.db4o.ObjectContainer;

public class InitDBedit {
	
	public String file;
		
	public InitDBedit(String configFile, String name){
		
		super();
		
		this.file = configFile;
		
		ObjectContainer db = Db4oEmbedded.openFile(Db4oEmbedded
		        .newConfiguration(), file);
		try {
		    // do something with db4o
			Story s = new Story();
			s.setName(name);
			s.setDescription("add a description for your story here");
			s.setStoryAuthor(new Author());
			
			ArrayList<Note>nlist = new ArrayList<Note>();
			
			Chapter c = new Chapter();
			c.setName("First Chapter");
			c.setDescription("add a description here");
			c.setNr(1);
			
			Character mc = new Character();
			
			Faction f = new Faction();
			Plot p = new Plot();
			Location l = new Location();
			l.setAddress("Somewhere on in a City or Not");
			l.setCity("This City");
			l.setCountry("This Country");
			l.setDescription("this is a place somewhere");
			l.setImage("an image");
			l.setMap("link to google maps?");
			l.setName("Somewhere");
			l.setShortName("SW");
			l.setWeb("link to homepage");
			Note n = new Note();
			n.setName("Welcome");
			n.setContent("a note");
			nlist.add(n);
			
			ArrayList<String>chars = new ArrayList<String>();
			chars.add(mc.toString());
			ArrayList<Scene>scenes = new ArrayList<Scene>();
			ArrayList<String>slist = new ArrayList<String>();
			ArrayList<String> locations = new ArrayList<String>();
			locations.add(l.toString());
			
			Scene sc = new Scene();
			sc.setCharacters(chars);
			sc.setDescription("add a descripion");
			sc.setLocation(l.toString());
			sc.setName("A New Start");
			sc.setNr(1);
			sc.setStatus("design");
			
			scenes.add(sc);
			slist.add(sc.toString());
			c.setScenes(scenes);
			p.setScenes(slist);
			
			db.store(p);
			db.store(s);
			db.store(c);
			db.store(mc);
			db.store(f);
			db.store(l);
			db.store(n);
			
			
		} finally {
		    db.close();
		}
	}

}
